<template>
    <el-dialog title="修改" visible :show-close="false" class="wrap" size="tiny">
        <i class="el-icon-close close" @click="cancel"></i>
        <el-form label-width="80px" class="form">
            <el-form-item label="工号">
                <el-input disabled v-model="form.jobNumber"></el-input>
            </el-form-item>
            <el-form-item label="现役老师">
                <el-input disabled v-model="form.person"></el-input>
            </el-form-item>
            <el-form-item label="选择老师">
                <el-select filterable  v-model="teacher" placeholder="请选择老师" class="select-block">
                    <el-option value="0" label="暂不选择"></el-option>
                    <el-option :label="v.zwm" :value="v.id" v-for="v in teacherList"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <el-button type="info" class="submit" @click="submit">确定</el-button>
    </el-dialog>
</template>

<script type="text/javascript">
    export default {
        props: ['params'],
        data () {
            return {
                dialogVisible: true,
                teacher: '',
                form: {
                    jobNumber: '',
                    person: ''
                },
                teacherList: []

            }
        },
        created () {
            console.log(this.params);
            this.getTeacherList()
            this.form = {
                jobNumber: this.params.row.gh,
                person: this.params.row.zwm
            }
        },
        methods: {
            submit () {
                
                this.axios.get( this.$store.state.api + 'ls/edit', {
                    params: {
                        id: this.params.row.id, 
                        empid: this.teacher
                    }
                })
                .then( res => {
                    console.log(res)
                    this.$emit('close',{type:'edit',cancel:false})
                    // this.teacherList = res.data.data.list;
                }).catch( res => {
                    console.log(res)
                })
            },
            cancel () {
                this.$emit('close',{type:'edit',cancel:true})
            },
            getTeacherList () {
                this.axios.get( this.$store.state.api + 'emp/list')
                .then( res => {
                    console.log(res)
                    this.teacherList = res.data.data.list;
                }).catch( res => {
                    console.log(res)
                })
            }
        }
    }
</script>

<style lang="less" scoped>
    .wrap {
        text-align: center;
    }
    .form {
        // width: 300px;
    }
    .select-block {
        display: block;
    }
    .submit {
        width: 120px;
    }
</style>